import { Inject, Injectable } from '@nestjs/common';
import { UserEntity } from 'src/user/entities/user.entity';
import { UserService } from 'src/user/user.service';

@Injectable()
export class AuthService {
  @Inject(UserService)
  private userService: UserService;

  /**
   * 用于验证请求中用户传递的id是否匹配，如果匹配则返回用户信息
   * @param payload
   */
  async validateUser(payload: { id: number }): Promise<UserEntity | null> {
    // return user
    return await this.userService.findOneById(payload.id);
  }
}
